﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmOrdenCompra.aspx.cs" Inherits="Box.Cliente.Almacen.frmOrdenCompra" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
    <script type="text/javascript">
        this.document.read(function () {
            $('p[id^=tblOrden]').hidden(true);


        });
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
   
    <div class="col-lg-12">
     <div class="panel panel-primary">
    	<div class="panel-heading">
    	    <h3>Registrar Nota de Compra</h3>
    	</div>
    	<div class="panel-body">
            <table id="tblOrden">
                <tr>
                    <td><asp:TextBox runat="server" ID="txtCodigo" Visible="False"/></td>
                </tr>
                <tr>
                    <td><label>Ruc:</label></td>
                    <td><asp:TextBox runat="server" ID="txtRuc" CssClass="form-control input-sm"></asp:TextBox></td>
                    <td><asp:Button runat="server" ID="btnBuscarProveedor" CssClass="btn btn-success" Text="Buscar" OnClick="btnBuscarProveedor_Click"/></td>
                </tr>
                <tr>
                    <td><label>Proveedor</label></td>
                    <td><asp:TextBox runat="server" ReadOnly="True" id="txtProveedor" CssClass="form-control input-sm"/></td>                    
                    <td><label>Fecha</label></td>
                    <td><asp:TextBox runat="server" ID="txtFecha" CssClass="form-control input-sm" TextMode="Date"/></td>
                </tr>
            </table>
            <br />
          
                <table>
					<tr>
						<td><label>Criterio:</label></td>
						<td><asp:TextBox ID="txtCriterio" placeholder="Buscar" runat="server"/></td>
						<td><asp:Button runat="server" CssClass="btn btn-primary btn-sm" Text="Buscar" ID="btnBuscar"/></td>
					</tr>
				</table>
				<br/><br/>
            
                        <div class="row">
                            <div class="col-md-6 .col-md-push-3">
                                  <div class="panel panel-primary">
                                          <div class="panel-heading">
                                                         <h3>Productos</h3>
                                         </div>
                                        <div class="panel-body">
                                                  <asp:UpdatePanel runat="server" ID="upProducto">
						<ContentTemplate>
							<asp:ListView ID="lvProductos"
								 ItemType="Box.Entities.Insumo" SelectMethod="GetProductos"
								runat="server" OnItemCommand="lvProductos_ItemCommand" >
								<EmptyDataTemplate>
									<b>No se han encontrado Productos..!!</b>
								</EmptyDataTemplate>
								<LayoutTemplate>
									<table class="table table-hover table-condensed">
										<thead>
											<tr>
												<th>Descripción</th>
												<th>Precio</th>
												<th>Stock</th>
												<th>Acciones</th>
											</tr>
										</thead>
										<tbody>
											<tr id="itemPlaceholder" runat="server"/>
										</tbody>
									 </table>
									<asp:DataPager ID="dpProductos" PagedControlID="lvProductos" runat="server" PageSize="2">
										<Fields>
											<asp:NextPreviousPagerField
												ButtonType="Link"
												ShowFirstPageButton="True"
												ShowLastPageButton="True"
												ShowNextPageButton="True"
												ShowPreviousPageButton="True"
												/>
										</Fields>
									</asp:DataPager>
								</LayoutTemplate>
								<ItemTemplate>
									<tr>
										<th><%# Item.NombreInsumo %></th>										
										<th><%# Item.Precio %></th>
										<th><%# Item.Marca %></th>
										<th>
											<asp:Button ID="btnAgregar"
												Text="Agregar" CommandName="AddDetalle"
												CommandArgument="<%# Item.Id %>"
												CssClass="btn btn-info btn-sm" runat="server"/>
										</th>
									</tr>
								</ItemTemplate>
							</asp:ListView>
						</ContentTemplate>
						<Triggers>
							<asp:AsyncPostBackTrigger ControlID="btnBuscar" EventName="Click"/>                            
						</Triggers>
					</asp:UpdatePanel>

                                        </div>
                                  </div>
                            </div>

                           <div class="col-md-6 .col-md-push-3">
                                  <div class="panel panel-primary">
                                          <div class="panel-heading">
                                                         <h3>Detalle</h3>
                                         </div>
                                        <div class="panel-body">
                                         <asp:UpdatePanel runat="server" ID="upDetalle">
                            <ContentTemplate>
                                <asp:ListView ID="lvDetCompra" runat="server" OnItemCommand="lvDetCompra_ItemCommand">
                                    <EmptyDataTemplate>
                                        <table class="table table-hover table-condensed">
                                            <thead>
                                                <tr>
                                                    <th>Descripcion</th>
                                                    <th>Medida</th>
                                                    <th>Cantidad</th>
                                                    <th>Precio</th>
                                                    <th>Monto</th>
                                                    <th>Acciones</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td colspan="6">
                                                        <h3>No tiene insumos agregados a su detalle..!!</h3>
                                                    </td>
                                                </tr>
                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </EmptyDataTemplate>
                                    <LayoutTemplate>
                                        <table class="table table-hover table-condensed">
                                            <thead>
                                                <tr>
                                                    
                                                    <th>Descripcion</th>
                                                    <th>Medida</th>
                                                    <th>Cantidad</th>
                                                    <th>Precio</th>
                                                    <th>Monto</th>
                                                    <th>Acciones</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr id="itemPlaceholder" runat="server" />
                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                    <td>
                                                        <%--<asp:Button runat="server"
                                                            ID="btnActualizarDetalle"
                                                            Text="Actualizar Detalle"
                                                            CommandName="ActualizarDetalle" />--%>
                                                    </td>
                                                    <td></td>
                                                    <td></td>
                                                    <td>
                                                        <h3>Total:</h3>
                                                    </td>
                                                    <td>
                                                        <h3>
                                                            <asp:Label ID="lblTotal" runat="server"></asp:Label>
                                                        </h3>
                                                    </td>
                                                    <td></td>
                                                </tr>
                                            </tfoot>
                                        </table>
                                    </LayoutTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td><%# Eval("Insumo.Id") %></td>
                                            <td><%# Eval("Insumo.DescripcionInsumo") %></td>
                                            <td><%# Eval("Insumo.MedidaInsumo") %></td>
                                            <td>
                                                <asp:TextBox CssClass="form-control input-sm" AutoPostBack="False" OnTextChanged="txtCantidad_TextChanged" runat="server" ID="txtCantidad" Text='<%# Bind("Cantidad") %>' Width="50px" /></td>
                                                <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" TargetControlID="txtCantidad" FilterType="Numbers"  runat="server"></ajaxToolkit:FilteredTextBoxExtender>

                                               <td>
                                                <asp:TextBox CssClass="form-control input-sm" runat="server" AutoPostBack="False" ID="txtPrecio" OnTextChanged="txtPrecio_TextChanged" Text='<%# Bind("PrecioUnit") %>' Width="50px" /></td>
                                               <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="txtPrecio" FilterType="Numbers, Custom"  ValidChars="."  runat="server"></ajaxToolkit:FilteredTextBoxExtender>
                                               <td><%# Eval("Monto") %></td>
                                            <td>
                                                <asp:Button ID="Button1" runat="server" Text="Quitar"
                                                    CssClass="btn btn-danger btn-sm"
                                                    CommandName="QuitarDetalle"
                                                    CommandArgument='<%# Eval("IdInsumo") %>' />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:ListView>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="lvDetCompra" EventName="ItemCommand" />
                                <asp:AsyncPostBackTrigger ControlID="lvProductos" EventName="ItemCommand" />
                            </Triggers>
                        </asp:UpdatePanel>
                                        </div>
                                  </div>
                            </div>
            
                       </div>

          


               
    	</div>
    	<div class="panel-footer">
            <asp:Button runat="server" ID="btnGuardar" CssClass="btn btn-success" Text="Guardar" OnClick="btnGuardar_Click" />
            <asp:Button runat="server" ID="btnLimpiar" CssClass="btn bg-info" Text="Limpiar" />
       </div>
    </div>
</asp:Content>
